package com.qumitech.visualnovel.controller.rest.novel;

import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import com.qumitech.visualnovel.model.common.BaseResponse;
import com.qumitech.visualnovel.service.novel.ReviewService;
import com.qumitech.visualnovel.model.dto.ReviewQueryDTO;
import com.qumitech.visualnovel.model.dto.PublishResultDTO;

@RestController
@Api(value = "审核发布模块", description = "审核发布模块")
public class ReviewRest {
    @Autowired
    private ReviewService reviewService;

    @ApiOperation(value = "小说审核发布列表", notes = "小说审核发布列表")
    @GetMapping("/api/review/list")
    public BaseResponse reviewList(ReviewQueryDTO param) {
        return reviewService.reviewList(param);
    }

    @ApiOperation(value = "小说审核结果", notes = "小说审核结果")
    @GetMapping("/api/review/result")
    public BaseResponse getReviewResult(@RequestParam(value="id", required=true) Long id) {
        return reviewService.getReviewResult(id);
    }

    @ApiOperation(value = "小说审核结果", notes = "小说审核结果")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id", value="审核记录id", required=true),
        @ApiImplicitParam(name="result", value="审核结果: Approved|Rejected", required=true),
        @ApiImplicitParam(name="message", value="审核内容", required=false),
        @ApiImplicitParam(name="attachments", value="审核图片", required=false)
    })
    @PostMapping("/api/review/result")
    public BaseResponse updateReviewResult(HttpServletRequest request) {
        return reviewService.updateReviewResult(request);
    }

    @ApiOperation(value = "小说审核发布列表", notes = "小说审核发布列表")
    @GetMapping("/api/publish/list")
    public BaseResponse publishList(ReviewQueryDTO param) {
        return reviewService.publishList(param);
    }

    @ApiOperation(value = "小说审核发布结果", notes = "小说审核发布结果")
    @GetMapping("/api/publish/result")
    public BaseResponse getPublishResult(@RequestParam(value="bookId", required=true) Long bookId) {
        return reviewService.getPublishResult(bookId);
    }

    @ApiOperation(value = "小说发布", notes = "小说发布")
    @PostMapping("/api/publish/result")
    public BaseResponse updatePublishResult(@RequestBody PublishResultDTO param) {
        return reviewService.updatePublishResult(param);
    }

    @ApiOperation(value = "小说审核简介", notes = "小说审核简介")
    @GetMapping("/api/review/book/summary")
    public BaseResponse reviewBookSummary(@RequestParam(value="bookId", required=true) Long bookId) {
        return reviewService.reviewBookSummary(bookId);
    }

    @ApiOperation(value = "小说章节发布列表", notes = "小说章节发布列表")
    @GetMapping("/api/review/chapter/list")
    public BaseResponse getReviewChapterList(@RequestParam(value="bookId", required=true) Long bookId) {
        return reviewService.getReviewChapterList(bookId);
    }

    @ApiOperation(value = "修改小说章节发布时间", notes = "修改小说章节发布时间")
    @PostMapping("/api/review/chapter")
    public BaseResponse updateReviewChapterList(@RequestBody JSONObject param) {
        return reviewService.updateReviewChapterList(param);
    }
}
